package day3;

public class Demo6 {
    public static void main(String[] args) {

        Demo6 d = new Demo6();
        d.sum();
        d.sum2();

    }

    public void sum(){
        int sum = 0;
        for (int i = 1; i <= 100; i ++){
            sum += i;
        }
        System.out.println("0到100内的数之和为:" + sum);
    }

    public void sum2(){
        int sum = 0;
        int sum2 = 0;
        for (int i = 1; i <= 100; i++){
            if (i % 2 != 0){
                sum += i;
            }else {
                sum2 += i;
            }
        }
        System.out.println("奇数之和为:" + sum);
        System.out.println("偶数之和为:" + sum2);
    }
}
